//
//  LGUnderwayView.m
//  lgdw
//
//  Created by mac on 16/1/19.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "LGUnderwayView.h"
#import "LGTopic.h"

#define Margin 10

@interface LGUnderwayView ()
/** 状态 */
@property (nonatomic , strong) UILabel *statusLabel;
/** 申请数量 */
@property (nonatomic , strong) UILabel *numLabel;
/** 总数量 */
@property (nonatomic , strong) UILabel *maxLabel;
@end

@implementation LGUnderwayView


- (void)setTopicModel:(LGTopic *)topicModel {
    
    _topicModel = topicModel;
    
    self.maxLabel.text = [NSString stringWithFormat:@"数量: %@   |",topicModel.member_max];
    self.numLabel.text = [NSString stringWithFormat:@"%@人申请",topicModel.member_num];
}

- (void)underwayViewWithMax:(NSNumber *)max Num:(NSNumber *)num {
    
    self.maxLabel.text = [NSString stringWithFormat:@"数量: %@   |",max];
    self.numLabel.text = [NSString stringWithFormat:@"%@人申请",num];
    
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    
    }
    return self;
}


- (void)setupUI {
    
    self.backgroundColor = [UIColor colorWithRed:66/255.0 green:175/255.0 blue:249/255.0 alpha:0.5];
    // 添加控件
    [self addSubview:self.statusLabel];
    [self addSubview:self.numLabel];
    [self addSubview:self.maxLabel];
    
    // 布局控件
    // 状态
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.left.mas_equalTo(self.mas_left).offset(Margin);
    }];
    // 申请人数
    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.mas_right).offset(-Margin);
    }];
    // 总数量
    [self.maxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.numLabel.mas_left).offset(-Margin);
    }];
    
}

#pragma -mark /***************** 懒加载 *****************/
// 状态
- (UILabel *)statusLabel {
    if (_statusLabel == nil) {
        _statusLabel = [[UILabel alloc] initWithTitle:@"报名中" FontSize:12 TextColor:[UIColor whiteColor]];
    }
    return _statusLabel;
}
// 总数量
- (UILabel *)maxLabel {
    if (_maxLabel == nil) {
        _maxLabel = [[UILabel alloc] initWithTitle:@"数量: -0   |" FontSize:12 TextColor:[UIColor whiteColor]];
    }
    return _maxLabel;
}
// 申请数量
- (UILabel *)numLabel {
    if (_numLabel == nil) {
        _numLabel = [[UILabel alloc] initWithTitle:@"-0申请人" FontSize:12 TextColor:[UIColor whiteColor]];
    }
    
    return _numLabel;
}
@end
